<template>
  <div class="app-container home">

    <div>
      热门搜索：<br>
      <span v-for="(h,index) in this.hot">{{h.value}} &nbsp;&nbsp;次数：{{h.score}}<br></span>
    </div>
    <br><br>

    <el-input v-model="word" placeholder="请输入内容" style="width:200px"/>
    <el-button @click="addHot">搜索</el-button>


    <!--  顶象验证码  -->
    <br><br><div ref="demo"></div>

  </div>
</template>

<script>
import {save,search} from "@/api/system/hot";
import {checkCode} from "@/api/login";
export default {
  name: "Index",
  data() {
    return {
      // 版本号
      version: "3.6.2",
      word:'',
      hot:[],
    };
  },
  mounted() {
    _dx.Captcha(this.$refs.demo, {
      // appId, 在控制台应用管理或应用配置模块获取
      appId: "52609c1127bb40c8121f29c26a3fb609",
      apiServer: 'https://dx-api.dingxiang-inc.com',
      // apiServer域名地址在控制台页面->无感验证->应用管页面左上角获取，必须填写完整包括https://。
      success: token => {
        // 获取验证码token，用于后端校验，注意获取token若是sl开头的字符串，则是前端网络不通生成的降级token,请检查前端网络及apiServer地址。
        console.log(token);
        checkCode(token).then(res=>{})
        this.$message.success('验证成功')
      }
    });
  },
  created() {
    this.word = ""
    this.searchHot();
  },
  methods: {
    searchHot(){
      search().then(res=>{
        this.hot=res.data
      })
    },
    addHot(){
      save(this.word).then(res=>{
        this.searchHot();
      })
    },
    goTarget(href) {
      window.open(href, "_blank");
    },
  },
};
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>

